package com.neuedu.oasystem.view;
/**
 * @author QXT
 */
import java.util.List;
import java.util.Scanner;

import com.neuedu.oasystem.entity.Customer;
import com.neuedu.oasystem.service.CustomerService;
import com.neuedu.oasystem.service.impl.CustomerServiceImpl;


public class OASystem {
	private Scanner scanner = null;
	private CustomerService customerService;
	
	public void init() {
		System.out.println("========================================");
		System.out.println("            欢迎使用办公管理系统                               ");
		System.out.println("========================================");
		System.out.println("1.客户类型管理");
		System.out.println("2.退出系统");
		System.out.println("========================================");
	}
	
	public void work() {
		scanner = new Scanner(System.in);
		customerService = new CustomerServiceImpl();
		boolean running = true;
		while (running) {
			init();
			System.out.println("请选择：");
			String choose = scanner.nextLine();
			switch (choose) {
			case "1":
				// 调用客户管理模块
				System.out.println("调用客户管理模块");
				customerManager();
				break;
			case "2":
				System.out.println("您选择了退出系统！");
				running = false;
				break;
			default:
				System.out.println("您的输入有误！");
				break;
			}
			
		}
		
	
		
	}
	private void customerManager() {
		boolean running = true;
		System.out.println("========================================");
		System.out.println("           欢迎使用办公管理系统                                 ");
		System.out.println("========================================");
		System.out.println("1.新增客户");
		System.out.println("2.修改客户");
		System.out.println("3.客户列表");
		System.out.println("4.返回上一级");
		System.out.println("========================================");
		System.out.println("请选择");
		String choose = scanner.nextLine();
		switch (choose) {
		case "1":
			System.out.println("新增客户");
			break;
         case "2":
			System.out.println("修改客户");
			break;
          case "3":
        	  System.out.println("客户列表");
        	  customerList();
	        break;
          case "4":
        	  System.out.println("返回上一级");
        	  running = false;
        	  break;

		default:
			System.out.println("您的输入有误！");
			break;
		}
	}
	private void customerList() {
		List<Customer> list = customerService.findAll();
		System.out.println("客户编号\t客户名称\t客户职务\t客户性别\t客户单位\t客户单位地址\t客户电话\t客户邮箱");
		for(Customer customer:list) {
			System.out.println(customer.getCustomerId()+"\t"
		                       +customer.getCustomerName()+"\t"
					           +customer.getCustomerPosition()+"\t"
					           +customer.getCustomerSex()+"\t"
					           +customer.getCustomerUnit()+"\t"
					           +customer.getCustomerAddress()+"\t"
					           +customer.getCustomerPhone()+"\t"
					           +customer.getCustomerEmail()+"\t");
		}
	}
	

}
